package com.echo.usedsfu;

import java.io.IOException;
import java.util.logging.Logger;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.echo.usedsfu.entity.Information;
import com.echo.usedsfu.persistence.PMF;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

public class DeleteAdServlet extends HttpServlet {
	private static final Logger log = Logger.getLogger(DeleteAdServlet.class.getName());
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp)throws IOException{
		String info_id = req.getParameter("del_info_id");
		PersistenceManager pm = PMF.get().getPersistenceManager();
		Key k = KeyFactory.createKey(Information.class.getSimpleName(), Long.parseLong(info_id));
		try{
			Information del_info = pm.getObjectById(Information.class, k);
			pm.deletePersistent(del_info);
		}finally{
			pm.close();
		}
		resp.sendRedirect("/index.jsp");
	}
}
